package com.vne.skyemart.model;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@Entity
@Table(name = "Cart",catalog = "skyemart_db")
public class Cart implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 8076559011081979022L;

	@Id
	@GeneratedValue
	@Column(name = "CartID",nullable = false,unique = true)
	private int cartID;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "UserID",nullable = false)
	private ADUser adUser;

	@OneToMany(fetch = FetchType.LAZY,mappedBy = "cart")
	private Set<Payment> payments = new HashSet<Payment>(0);

	@Column(name = "TotalCost",length = 20)
	private String totalCost;

	@OneToMany(fetch = FetchType.LAZY,mappedBy = "cart")
	private Set<ShippingType> shippingType = new HashSet<ShippingType>(0);
	
	@OneToMany(fetch = FetchType.LAZY,mappedBy = "pk.cart", cascade = CascadeType.ALL)
	private Set<CartItem> cartItem = new HashSet<CartItem>(0);
	/**
	 * CONSTRUCTOR
	 */
	public Cart() {}
	
	

	public Cart(int cartID, String totalCost, Set<CartItem> cartItem) {
		this.cartID = cartID;
		this.totalCost = totalCost;
		this.cartItem = cartItem;
	}



	/**
	 * GETTER AND SETTER
	 * 
	 */
	public int getCartID() {
		return cartID;
	}
	public void setCartID(int cartID) {
		this.cartID = cartID;
	}
	public ADUser getAdUser() {
		return adUser;
	}
	public void setAdUser(ADUser adUser) {
		this.adUser = adUser;
	}
	public Set<Payment> getPayments() {
		return payments;
	}
	public void setPayments(Set<Payment> payments) {
		this.payments = payments;
	}
	public String getTotalCost() {
		return totalCost;
	}
	public void setTotalCost(String totalCost) {
		this.totalCost = totalCost;
	}
	public Set<ShippingType> getShippingType() {
		return shippingType;
	}
	public void setShippingType(Set<ShippingType> shippingType) {
		this.shippingType = shippingType;
	}
	public Set<CartItem> getCartItems() {
		return cartItem;
	}
	public void setCartItems(Set<CartItem> cartItem) {
		this.cartItem = cartItem;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
}
